import axios from 'axios';
const open_url = '/open';
const back_url = '/back';

const open_client = axios.create({
  timeout: 15000,
  baseURL:open_url,
  headers: {
    'Content-Type': 'application/json',
    'Access-Control-Allow-Origin': '*',
    'agent': 'Web',
    'token':'-2801744071852360856'
  },
});
const back_client = axios.create({
  timeout: 15000,
  baseURL:back_url,
  headers: {
    'Content-Type': 'application/json',
    'Access-Control-Allow-Origin': '*',
    'agent': 'Web',
    'token':'-2801744071852360856'
  },
});
open_client.defaults.withCredentials = true;
open_client.interceptors.request.use(config => {
  const token = localStorage.getItem("token")
  if (token) {
    config.headers.Cookie = config.headers.Cookie+'token='+token;
  }
  return config;
});
back_client.defaults.withCredentials = true;
back_client.interceptors.request.use(config => {
  const token = localStorage.getItem("token")
  if (token) {
    config.headers.Cookie = config.headers.Cookie+'token='+token;
  }
  return config;
});

export const back_api = back_client;
export const open_api = open_client;